<?php 
namespace Admin\Controller;
use Think\Controller;
class ApiController extends Controller {

	 public function api(){
        if(IS_POST){
             $data=I();
            if(empty($data['city'])){
                $this->ajaxReturn(['code'=>10001,'msg'=>'省份不能为空']);die;
            }
            if(empty($data['money'])){
                $this->ajaxReturn(['code'=>10001,'msg'=>'金额不能为空']);die;
            }
            if(empty($data['score'])){
                $this->ajaxReturn(['code'=>10001,'msg'=>'积分不是有效的']);die;
            }
             $model=M('pointcard');
             
            $res=$model->where(['province'=>$data['city'],'money'=>$data['money'],'score'=>$data['score']])->find();
            // print_r($res);die;
            if(!$res){
                 $this->ajaxReturn(['code'=>10001,'msg'=>'没有此积分卡']);die;
            }else{
                 $b=$model->where(['province'=>$data['city'],'money'=>$data['money'],'score'=>$data['score']])->setInc('sum_num');
                 if($b){
                     $this->ajaxReturn(['code'=>10000,'msg'=>'操作成功']);
                 }else{
                    $this->ajaxReturn(['code'=>10000,'msg'=>'操作失败']);
                 }
            }
        }
       

    }



}


















 ?>